<?php

##################################################
#
# Copyright (c) 2004-2006 OIC Group, Inc.
# Written and Designed by James Hunt
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################

class contactmodule_config {
	function form($object) {
		$i18n = exponent_lang_loadFile('datatypes/contactmodule_config.php');
		
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();
		
		$form = new form();
		if (!isset($object->id)) {
			$object->subject = $i18n['default_subject'];
			$object->replyto_address = '';
			$object->from_name = $i18n['default_from_name'];
			$object->from_address = 'info@'.HOSTNAME;
			$object->final_message = $i18n['default_final_message'];
			$object->use_captcha = 1;
			// Jun 6, 2011 - trungdt - Add google map locationsupport
			$object->googlemap_key = "";
			$object->show_map = 0;
			$object->map_zoom = 5;
			$object->lat_long1 = "41.069336,29.012218"; // Turkey
			$object->lat_long2 = "41.069336,29.012118"; // Turkey
            $object->location_des = "Please enter your location description here"; 
			$object->location_des2 = "Please enter your location description here";
			// Jun 6, 2011 - trungdt - Add google map locationsupport - End
		} else {
			$form->meta('id',$object->id);
		}
		
		$form->register('subject',$i18n['subject'],new textcontrol($object->subject));
		$form->register('from_name',$i18n['from_name'],new textcontrol($object->from_name));
		$form->register('from',$i18n['from'],new textcontrol($object->from_address));
		$form->register('replyto',$i18n['replyto'],new textcontrol($object->replyto_address));
		$form->register('final_message',$i18n['final_message'],new htmleditorcontrol($object->final_message));
		$form->register('use_captcha',exponent_lang_getText('Require CAPTCHA to submit form?'),new checkboxcontrol($object->use_captcha));		
		
		// Jun 6, 2011 - trungdt - Add google map locationsupport
		$show_map_array=array();
		$show_map_array[0]="Show nothing";
		$show_map_array[1]="Show location with Google Map";
		$show_map_array[2]="Show Location Description only";
		$form->register('show_map',"Show Map",new dropdowncontrol($object->show_map,$show_map_array));
		
		$form->register('googlemap_key',"Google map API key",new textcontrol($object->googlemap_key));
		$form->register('',NULL,new htmlcontrol("<a target=_blank href='http://code.google.com/apis/loader/signup.html'>Get Google Map API Key</a>"));
		$form->register('lat_long1',"Longtude Latude Office 1",new textcontrol($object->lat_long1));
        $form->register('location_des',"Office 1 Info",new htmleditorcontrol($object->location_des));
		$form->register('map_zoom',"Map Zoom (0-15)",new textcontrol($object->map_zoom));
        $form->register('location_des2',"Office 2 Info",new htmleditorcontrol($object->location_des));
        $form->register('lat_long2',"Longtude Latude Office 2",new textcontrol($object->lat_long2));
		// end map support
		$form->register('submit','',new buttongroupcontrol($i18n['save'],'',$i18n['cancel']));
		
		return $form;
	}
	
	function update($values,$object) {
		if (!defined('SYS_FORMS')) include_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();
		
		$object->subject = $values['subject'];
		$object->from_name = $values['from_name'];
		$object->from_address = $values['from'];
		$object->replyto_address = $values['replyto'];
		$object->final_message = htmleditorcontrol::parseData('final_message',$values);
		$object->use_captcha = (isset($values['use_captcha']) ? 1 : 0);
		
		// Jun 6, 2011 - trungdt - Add google map locationsupport
        $object->location_des = htmleditorcontrol::parseData('location_des',$values);
		$object->location_des2 = htmleditorcontrol::parseData('location_des2',$values);
		$object->lat_long1 = $values['lat_long1'];
		$object->lat_long2 = $values['lat_long2'];
		$object->map_zoom = intval($values['map_zoom']);
		$object->googlemap_key = $values['googlemap_key'];
		$object->show_map = intval($values['show_map']);
		// Jun 6, 2011 - trungdt - Add google map locationsupport - end
		
		return $object;
	}
}

?>
